package com.zx.erp.purchase.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zx.erp.purchase.bean.CProduct;
import com.zx.erp.purchase.mapper.CProductMapper;
import com.zx.erp.purchase.service.CProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zx.erp.sys.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 作者信息
 * @since 2021-11-10
 */
@Service
public class CProductServiceImpl extends ServiceImpl<CProductMapper, CProduct> implements CProductService {
@Autowired
private CProductMapper cProductMapper;
    @Override
    public Page<CProduct> selectP(CProduct cProduct, Integer pageNo, Integer pageSize) {
        // Step1：创建一个 Page 对象
        Page<CProduct> page = new Page<>(pageNo, pageSize);
        // Step2：调用 mybatis-plus 提供的分页查询方法
        Page<CProduct> pageInfo = cProductMapper.selectP(page, cProduct);

        return pageInfo;
    }
    @Override
    public List<CProduct> findbyTypeId(Integer id) {
        return cProductMapper.findbytypeid(id);
    }
    public PageInfo<CProduct> findAll(CProduct cProduct, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<CProduct> cProducts = cProductMapper.selectAll(cProduct);
        PageInfo<CProduct> pageInfo=new PageInfo<CProduct>(cProducts);
        return pageInfo;
    }
}
